#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
typedef pair<int, int> PII;
#define x first
#define y second
const int N = 2e5 + 10, M = N * 20;
int h[N], e[M], ne[M], w[M], idx;
int dis[N];
int st[N];
int n, m, k;
int s, t;
void add(int a, int b, int c)
{
	e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx++;
}

void dij(int s)
{
	priority_queue<PII, vector<PII>, greater<PII>>heap;
	memset(dis, 0x3f, sizeof(dis));
	dis[s] = 0;
	heap.push({ 0,s });
	while (heap.size()) {
		PII t = heap.top();
		heap.pop();
		int ver = t.y;
		int distance = t.x;
		//cout << "ver===" << ver << endl;
		if (st[ver])continue;
		st[ver] = 1;
		for (int i = h[ver]; ~i; i = ne[i]) {
			int j = e[i];
			//cout << "j==" << j << endl;
			if (dis[j] > distance + w[i] && !st[j]) {
				dis[j] = distance + w[i];
				//cout << "dis[j]==" << dis[j] << endl;
				heap.push({ dis[j],j });
			}
		}
	}
}
int main()
{
	cin >> n >> m >> k;
	cin >> s >> t;
	s++, t++;
	memset(h, -1, sizeof(h));
	while (m--) {
		int a, b, c;
		cin >> a >> b >> c;
		a++, b++;
		add(a, b, c);
		add(b, a, c);
		for (int i = 0; i <= k; i++) {
			add(a + i * n, b + i * n, c);
			add(b + i * n, a + i * n, c);
			add(a + i * n, b + (i + 1) * n, 0);
			add(b + i * n, a + (i + 1) * n, 0);
		}
	}
	dij(s);
	////cout << dis[t] << endl;
	int ans = 1e9;
	////cout << dis[2] << endl;
	////cout << dis[t] << endl;
	/*for (int i = 1; i <= n; i++) {
		cout << "dis[i]==" << dis[i] << endl;
	}*/
	for (int i = 0; i <= k; i++) {
		ans = min(ans, dis[t + n * i]);
		//cout << "dis[t]==" << dis[t + n * i] << endl;
	}
	cout << ans << endl;
	return 0;
}